<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Demo后台管理系统</title>
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
</head>

<section class="content-header">
    <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
        <li><a href="#">观元管理</a></li>
        <li class="active">实战视频</li>
    </ol>
</section>
<!-- Main content -->
<section class="content">
    <div class="jax-box">
        <form id="formSearch" class="form-horizontal">
            <div class="form-group">
                <div class="col-md-4 col-sm-6">
                    <label class="control-label  col-xs-4" for="title">视频标题:</label>
                    <div class="col-xs-8">
                        <input type="text" class="form-control" id="title">
                    </div>
                </div>
                <shiro:hasPermission name="user:list">
                    <div class="col-md-1 col-sm-6 " style="text-align:left;">
                        <button type="button" id="btn_query" class="btn btn-info">查询</button>
                    </div>
                </shiro:hasPermission>
            </div>
        </form>
    </div>
    <div class="jax-box jax-box-table">
        <div id="toolbar" class="btn-group">
            <shiro:hasPermission name="user:add">
                <button id="btn_add" type="button" class="btn btn-primary" onclick="location.href='/admin#tgqmdj/articlelist'" >
                    <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>添加视频
                </button>
            </shiro:hasPermission>
            <shiro:hasPermission name="szsp:batchDelete">
                <button id="btn_batch_delete" type="button" class="btn btn-danger">
                    <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>批量删除
                </button>
            </shiro:hasPermission>
        </div>
        <table id="table"></table>
    </div>
</section>



<script th:src="@{/libs/select/select2.min.js}"></script>
<script>
    var editFlag = "[[${@perms.hasPerm('user:edit')}]]";
    var deleteFlag = "[[${@perms.hasPerm('user:delete')}]]";
    var assignRoleFlag="[[${@perms.hasPerm('user:assignRole')}]]";
    var userIdStr;//批量用户id
    var roleIdStr;//分配的角色
    var selectRoleIds;
    var userIdChecked;
    var loadRoleCount=0;
    var columns = [
        {checkbox: true },
        {
            field: 'title',
            title: '文章标题',
            align : "center"
        },{
            field: 'author',
            title: '作者',
            align : "center"
        },
        {
            field: 'createat',
            title: '添加时间',
            align : "center",
            formatter : function(value,row, index) {
                return Core.longMsTimeConvertToDateTime(value);
            }
        },
        {
            field : 'operation',
            title : '操作',
            align : "center",
            formatter : function(value,
                                 row, index) {
                var edit = editFlag=="true" ?  '<a class="table-btn table-btn-info" href="javascript:void(0)" onclick="editUser('+row.articleId+')">编辑</a>' : '';
                var del = deleteFlag=="true"  ?  '<a  class="table-btn table-btn-danger" href="javascript:void(0)" onclick="deleteUser('+row.articleId+')">删除</a>' : '';
                return edit + del;
            }
        }];
    var options={
        id:"#table",
        url: '/tgqmdj/szsplist',
        columns:columns,
        toolbar: '#toolbar',
        showRefresh: true,
        queryParams : queryParams
    }
    Core.initTable(options);

    /*查询用户参数*/
    function queryParams(params) {
        var temp = { //这里的键的名字和控制器的变量名必须一致，这边改动，控制器也需要改成一样的
            limit : params.limit, //页面大小
            offset : params.offset, //页码
            title : $("#title").val()
        };
        return temp;
    }


    /*编辑*/
    function editUser(articleId) {
        location.href="/admin#tgqmdj/articlelist?articleId="+articleId;
    }



</script>